
package com.shop.cloud.mall.api.controller;

import com.shop.cloud.common.core.util.R;
import com.shop.cloud.common.portal.annotation.ApiLogin;
import com.shop.cloud.mall.api.service.SignRecordService;
import com.shop.cloud.common.portal.util.ThirdSessionHolder;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 签到记录
 *
 * @author
 * @date 2021-01-13 15:29:30
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/signrecord")
@Tag(description = "signrecord", name = "签到记录API")
public class SignRecordController {

    private final SignRecordService signRecordService;

    /**
     * 签到记录查询
     * @return R
     */
    @Operation(summary = "签到记录查询")
    @GetMapping("/user")
	@ApiLogin
    public R getById() {
        return R.ok(signRecordService.getSignRecord(ThirdSessionHolder.getUserId()));
    }

	/**
	 * 用户签到
	 * @return R
	 */
	@Operation(summary = "用户签到")
	@PostMapping("/user")
	@ApiLogin
	public R userSign(){
		return R.ok(signRecordService.userSign(ThirdSessionHolder.getUserId()));
	}
}
